<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    await返回的是一个promise对象
</body>
<script>
    const p = new Promise((resolve, reject) => {
        // resolve("执行成功"); // promise对象返回成功的状态
        reject("执行失败"); // promise对象返回失败的状态
    });
    async function main() {
        try {
            let result = await p; // result = "执行成功"
            console.log(result);
        } catch (error) {
            // 失败需要用try...catch捕获
            console.log(error);
        }
    }
    main();
</script>

</html>